Skip to content

Register getGraph custom action for Radius.Core/applications - #11796

Merged
willtsai merged 20 commits into
mainfrom
copilot/fix-getgraph-route-404
May 8, 2026
Merged

willtsai merged 20 commits into
mainfrom
copilot/fix-getgraph-route-404

Conversation

Copilot AI commented May 1, 2026 •

Copy link
Copy Markdown
Contributor

Description

POST .../providers/Radius.Core/applications/{app}/getGraph returned 404 because the namespace builder for Radius.Core never wired the getGraph custom action — only Applications.Core/applications did. The OpenAPI route exists but had no controller, blocking app graph rendering in the dashboard.

  • New controller: GetGraphv20250801preview in pkg/corerp/frontend/controller/applications/v20250801preview/getgraph.go (package v20250801preview). Placed in a v20250801preview/ subpackage to match the convention established by pkg/corerp/frontend/controller/environments/v20250801preview/. Typed against datamodel.Application_v20250801preview and uses the Application20250801* converters.

  • Shared helper: Extracted a ComputeGraphResponse exported helper in the parent pkg/corerp/frontend/controller/applications package so both the Applications.Core and Radius.Core getGraph controllers reuse the same graph-listing logic (resource type discovery, application-/environment-scoped listing, and graph computation) without duplication.

  • Stricter validation: ComputeGraphResponse uses resources.ParseResource (instead of resources.Parse) to validate the environment ID is a named resource, rejecting collection or custom-action IDs. The error is wrapped with fmt.Errorf for context.

  • Wiring: SetupRadiusCoreNamespace in pkg/corerp/setup/setup.go now registers Custom["getGraph"] on the applications resource, analogous to the Applications.Core/applications registration.

  • Tests: Unit test for the not-found path on the new controller, plus a router assertion in setup_test.go that POST .../radius.core/applications/app0/getgraph resolves to ACTIONGETGRAPH. Additional tests targeting the lines flagged by Codecov:

    • ComputeGraphResponse invalid-environment-ID error path.
    • ComputeGraphResponse UCP error-propagation path, driven by an httptest UCP server returning 500 on /planes/radius/local/providers.
    • ComputeGraphResponse listAllResourcesByApplication error path (lines 62-63), driven by an httptest server returning a resource type then failing on GetProviderSummary.
    • ComputeGraphResponse listAllResourcesByEnvironment error path (lines 67-68), driven by an httptest server where application-scoped listing succeeds but environment-scoped listing returns 500.
    • Database error path through GetGraph.Run and GetGraphv20250801preview.Run (non-NotFound Get error is propagated).
    • End-to-end success path through both Run methods into ComputeGraphResponse, driven by an httptest UCP server returning an empty providers list to yield an empty graph.

    Coverage on the new shared helper rose from 0% to ~87.5%, both Run methods are at 100%, and the v20250801preview getGraph package is at 100%.

Custom: map[string]builder.Operation[datamodel.Application_v20250801preview]{
    "getGraph": {
        APIController: func(opt apictrl.Options) (apictrl.Controller, error) {
            return app_v20250801_ctrl.NewGetGraphv20250801preview(opt, *recipeControllerConfig.UCPConnection)
        },
    },
},

Type of change

  • This pull request fixes a bug in Radius and has an approved issue (issue link required).

Contributor checklist

Please verify that the PR meets the following requirements, where applicable:

  • An overview of proposed schema changes is included in a linked GitHub issue.
    • Yes
    • Not applicable
  • A design document is added or updated under eng/design-notes/ in this repository, if new APIs are being introduced.
    • Yes
    • Not applicable
  • The design document has been reviewed and approved by Radius maintainers/approvers.
    • Yes
    • Not applicable
  • A PR for resource-types-contrib is created, if resource types or recipes are affected by the changes in this PR.
    • Yes
    • Not applicable
  • A PR for dashboard is created, if the Radius Dashboard is affected by the changes in this PR.
    • Yes
    • Not applicable
  • A PR for the documentation repository is created, if the changes in this PR affect the documentation or any user facing updates are made.
    • Yes
    • Not applicable

Copilot AI changed the title [WIP] Fix getGraph route to prevent 404 error Register getGraph custom action for Radius.Core/applications May 1, 2026
Copilot AI requested a review from willtsai May 1, 2026 17:55
@willtsai

willtsai commented May 1, 2026

Copy link
Copy Markdown
Contributor

@copilot - should the new controller follow the file path conventions established in pkg/corerp/frontend/controller/environments instead?

Copilot AI commented May 1, 2026

Copy link
Copy Markdown
Contributor Author

@copilot - should the new controller follow the file path conventions established in pkg/corerp/frontend/controller/environments instead?

Good catch — moved the new controller into pkg/corerp/frontend/controller/applications/v20250801preview/getgraph.go (package v20250801preview), matching the environments/v20250801preview/ layout. Extracted a shared ComputeGraphResponse helper in the parent applications package so both controllers reuse the same graph logic. Done in 7dc9649.

@github-actions

github-actions Bot commented May 1, 2026 •

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Co-authored-by: Will <28876888+willtsai@users.noreply.github.com>
Signed-off-by: Will <28876888+willtsai@users.noreply.github.com>
@willtsai willtsai added the pr:standard Ongoing maintenance, minor improvements, documentation updates, and routine development work label May 1, 2026
@github-actions

github-actions Bot commented May 1, 2026 •

Copy link
Copy Markdown

Unit Tests

    2 files  ± 0    421 suites  +1   7m 18s ⏱️ +39s
5 034 tests +11  5 032 ✅ +11  2 💤 ±0  0 ❌ ±0 
6 061 runs  +11  6 059 ✅ +11  2 💤 ±0  0 ❌ ±0 

Results for commit e383e73. ± Comparison against base commit 8ad0d19.

♻️ This comment has been updated with latest results.

@codecov

codecov Bot commented May 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 51.40%. Comparing base (8ad0d19) to head (e383e73).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11796      +/-   ##
==========================================
+ Coverage   51.19%   51.40%   +0.20%     
==========================================
  Files         715      716       +1     
  Lines       45081    45106      +25     
==========================================
+ Hits        23079    23186     +107     
+ Misses      19803    19721      -82     
  Partials     2199     2199              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@willtsai

willtsai commented May 1, 2026

Copy link
Copy Markdown
Contributor

@copilot - please take a look at the codecov report here and add the necessary tests to improve coverage.

Copilot AI commented May 1, 2026 •

Copy link
Copy Markdown
Contributor Author

@copilot - please take a look at the codecov report here and add the necessary tests to improve coverage.

Added a test for the ComputeGraphResponse helper covering the invalid-environment-ID parse-error path in cf948d6, which lifts coverage on the new shared helper from 0%. The remaining branches (UCP ListAllResourceTypesNames / listAllResourcesByApplication / listAllResourcesByEnvironment) make live HTTP calls through an inline-constructed UCPApplicationsManagementClient, so covering them would require introducing a UCP HTTP test server (or DI'ing the client) — happy to do that in a follow-up if you'd like, but it's a meaningfully larger refactor than the original bug fix.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • app.codecov.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI requested a review from willtsai May 1, 2026 22:52
@willtsai

willtsai commented May 4, 2026

Copy link
Copy Markdown
Contributor

@copilot - are you able to view the codecov report via this link to review and improve the test coverage as called out by the report?
https://app.codecov.io/gh/radius-project/radius/pull/11796?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=radius-project

@willtsai

willtsai commented May 6, 2026

Copy link
Copy Markdown
Contributor

This is now ready for review. I've built and validated that this works, see below.

Radius v0.56.1

$ curl -X POST \
  '[http://localhost:8001/apis/api.ucp.dev/v1alpha3/planes/radius/local/resourcegroups/default/provider…](http://localhost:8001/apis/api.ucp.dev/v1alpha3/planes/radius/local/resourcegroups/default/providers/Radius.Core/applications/aca-testapp-dapr/getGraph?api-version=2025-08-01-preview%27) \
  -H 'Content-Type: application/json' \
  -d '{}'
{
  "error": {
    "code": "NotFound",
    "message": "The request 'POST /planes/radius/local/resourcegroups/default/providers/radius.core/applications/aca-testapp-dapr/getgraph' is invalid."
  }
}

Radius build of this branch

$ curl -X POST \
  '[http://localhost:8001/apis/api.ucp.dev/v1alpha3/planes/radius/local/resourcegroups/default/provider…](http://localhost:8001/apis/api.ucp.dev/v1alpha3/planes/radius/local/resourcegroups/default/providers/Radius.Core/applications/aca-testapp-dapr/getGraph?api-version=2025-08-01-preview%27) \
  -H 'Content-Type: application/json' \
  -d '{}'
{
  "resources": [
    {
      "connections": [
        {
          "direction": "Inbound",
          "id": "/planes/radius/local/resourcegroups/default/providers/Radius.Compute/containers/backend"
        }
      ],
      "id": "/planes/radius/local/resourcegroups/default/providers/Applications.Dapr/stateStores/statestore",
      "name": "statestore",
      "outputResources": [
        {
          "id": "/subscriptions/85716382-7362-45c3-ae03-2126e459a123/resourceGroups/willtsai-prod-aca/providers/Microsoft.App/managedEnvironments/aca-wp-egress-env/daprComponents/statestore",
          "name": "statestore",
          "type": "Microsoft.App/managedEnvironments/daprComponents"
        },
        {
          "id": "/subscriptions/85716382-7362-45c3-ae03-2126e459a123/resourceGroups/willtsai-prod-aca/providers/Microsoft.App/managedEnvironments/aca-wp-egress-env/daprComponents/statestore",
          "name": "statestore",
          "type": "Microsoft.App/managedEnvironments/daprComponents"
        },
        {
          "id": "/subscriptions/85716382-7362-45c3-ae03-2126e459a123/resourceGroups/willtsai-prod-aca/providers/Microsoft.Cache/redis/recipevolsfgywvnst6",
          "name": "recipevolsfgywvnst6",
          "type": "Microsoft.Cache/redis"
        },
        {
          "id": "/subscriptions/85716382-7362-45c3-ae03-2126e459a123/resourceGroups/willtsai-prod-aca/providers/Microsoft.Cache/redis/recipevolsfgywvnst6",
          "name": "recipevolsfgywvnst6",
          "type": "Microsoft.Cache/redis"
        }
      ],
      "provisioningState": "Succeeded",
      "type": "Applications.Dapr/stateStores"
    },
    {
      "connections": [
        {
          "direction": "Outbound",
          "id": "/planes/radius/local/resourcegroups/default/providers/Applications.Dapr/stateStores/statestore"
        }
      ],
      "id": "/planes/radius/local/resourcegroups/default/providers/Radius.Compute/containers/backend",
      "name": "backend",
      "outputResources": [
        {
          "id": "/subscriptions/85716382-7362-45c3-ae03-2126e459a123/resourceGroups/willtsai-prod-aca/providers/Microsoft.App/containerApps/backend-qjpn7qj7",
          "name": "backend-qjpn7qj7",
          "type": "Microsoft.App/containerApps"
        },
        {
          "id": "/subscriptions/85716382-7362-45c3-ae03-2126e459a123/resourceGroups/willtsai-prod-aca/providers/Microsoft.App/containerApps/backend-qjpn7qj7",
          "name": "backend-qjpn7qj7",
          "type": "Microsoft.App/containerApps"
        }
      ],
      "provisioningState": "Succeeded",
      "type": "Radius.Compute/containers"
    },
    {
      "connections": [],
      "id": "/planes/radius/local/resourcegroups/default/providers/Radius.Compute/containers/frontend",
      "name": "frontend",
      "outputResources": [
        {
          "id": "/subscriptions/85716382-7362-45c3-ae03-2126e459a123/resourceGroups/willtsai-prod-aca/providers/Microsoft.App/containerApps/frontend-62uirid4",
          "name": "frontend-62uirid4",
          "type": "Microsoft.App/containerApps"
        },
        {
          "id": "/subscriptions/85716382-7362-45c3-ae03-2126e459a123/resourceGroups/willtsai-prod-aca/providers/Microsoft.App/containerApps/frontend-62uirid4",
          "name": "frontend-62uirid4",
          "type": "Microsoft.App/containerApps"
        }
      ],
      "provisioningState": "Succeeded",
      "type": "Radius.Compute/containers"
    }
  ]
}

@willtsai
willtsai marked this pull request as ready for review May 6, 2026 18:43
@willtsai
willtsai requested review from a team as code owners May 6, 2026 18:43
Copilot AI review requested due to automatic review settings May 6, 2026 18:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes the Radius.Core/applications/{app}/getGraph custom action returning 404 by wiring the custom action into the Radius.Core namespace builder, adding a v20250801preview controller for the action, and extracting shared graph-computation logic so both Applications.Core and Radius.Core controllers reuse it.

Changes:

  • Register getGraph as a custom action on Radius.Core/applications in SetupRadiusCoreNamespace.
  • Add a v20250801preview getGraph controller for Radius.Core/applications and route it to shared graph computation.
  • Extract ComputeGraphResponse helper and expand unit/router tests for both namespaces and error/success paths.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/corerp/setup/setup.go Registers getGraph custom action for Radius.Core/applications and wires it to the new controller.
pkg/corerp/setup/setup_test.go Adds router assertion coverage for POST .../radius.core/applications/{app}/getgraph resolving to ACTIONGETGRAPH.
pkg/corerp/frontend/controller/applications/v20250801preview/getgraph.go Introduces Radius.Core v20250801preview getGraph controller delegating to shared graph logic.
pkg/corerp/frontend/controller/applications/v20250801preview/getgraph_test.go Adds unit tests for not-found, DB error propagation, and success path for the new controller.
pkg/corerp/frontend/controller/applications/getgraph.go Extracts ComputeGraphResponse helper used by both getGraph controllers.
pkg/corerp/frontend/controller/applications/getgraph_test.go Adds targeted unit tests to cover ComputeGraphResponse error paths and controller DB/success paths.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Will <28876888+willtsai@users.noreply.github.com>
…GraphResponse

Switch from resources.Parse to resources.ParseResource for environment ID
validation to ensure the stored value is a named resource (not a collection
or custom-action ID). Wrap the error with fmt.Errorf for context.

Agent-Logs-Url: https://github.com/radius-project/radius/sessions/45f8841e-e581-446f-ade0-d08975e20c38

Co-authored-by: willtsai <28876888+willtsai@users.noreply.github.com>
@willtsai

willtsai commented May 6, 2026

Copy link
Copy Markdown
Contributor

Confirmed on the dasboard as well where Radius.Core/applications graph is being rendered:
image

@willtsai
willtsai removed their request for review May 6, 2026 23:02
Copilot AI requested a review from willtsai May 8, 2026 21:11
@radius-functional-tests

radius-functional-tests Bot commented May 8, 2026 •

Copy link
Copy Markdown

Radius functional test overview

🔍 Go to test action run

Click here to see the test run details
Name Value
Repository radius-project/radius
Commit ref e383e73
Unique ID func69db2c6f41
Image tag pr-func69db2c6f41
  • gotestsum 1.13.0
  • KinD: v0.29.0
  • Dapr: 1.14.4
  • Azure KeyVault CSI driver: 1.4.2
  • Azure Workload identity webhook: 1.3.0
  • Bicep recipe location ghcr.io/radius-project/dev/test/testrecipes/test-bicep-recipes/<name>:pr-func69db2c6f41
  • Terraform recipe location http://tf-module-server.radius-test-tf-module-server.svc.cluster.local/<name>.zip (in cluster)
  • applications-rp test image location: ghcr.io/radius-project/dev/applications-rp:pr-func69db2c6f41
  • dynamic-rp test image location: ghcr.io/radius-project/dev/dynamic-rp:pr-func69db2c6f41
  • controller test image location: ghcr.io/radius-project/dev/controller:pr-func69db2c6f41
  • ucp test image location: ghcr.io/radius-project/dev/ucpd:pr-func69db2c6f41
  • deployment-engine test image location: ghcr.io/radius-project/deployment-engine:latest

Test Status

⌛ Building Radius and pushing container images for functional tests...
✅ Container images build succeeded
⌛ Publishing Bicep Recipes for functional tests...
✅ ucp-cloud functional tests succeeded
✅ Recipe publishing succeeded
⌛ Starting ucp-cloud functional tests...
⌛ Starting corerp-cloud functional tests...
✅ ucp-cloud functional tests succeeded
✅ corerp-cloud functional tests succeeded
✅ corerp-cloud functional tests succeeded

@willtsai
willtsai merged commit 79aeb54 into main May 8, 2026
59 checks passed
@willtsai
willtsai deleted the copilot/fix-getgraph-route-404 branch May 8, 2026 21:58
Reshrahim pushed a commit to Reshrahim/radius that referenced this pull request Jun 15, 2026
…project#11796)

# Description

`POST .../providers/Radius.Core/applications/{app}/getGraph` returned
404 because the namespace builder for `Radius.Core` never wired the
`getGraph` custom action — only `Applications.Core/applications` did.
The OpenAPI route exists but had no controller, blocking app graph
rendering in the dashboard.

- **New controller**: `GetGraphv20250801preview` in
`pkg/corerp/frontend/controller/applications/v20250801preview/getgraph.go`
(package `v20250801preview`). Placed in a `v20250801preview/` subpackage
to match the convention established by
`pkg/corerp/frontend/controller/environments/v20250801preview/`. Typed
against `datamodel.Application_v20250801preview` and uses the
`Application20250801*` converters.
- **Shared helper**: Extracted a `ComputeGraphResponse` exported helper
in the parent `pkg/corerp/frontend/controller/applications` package so
both the `Applications.Core` and `Radius.Core` getGraph controllers
reuse the same graph-listing logic (resource type discovery,
application-/environment-scoped listing, and graph computation) without
duplication.
- **Stricter validation**: `ComputeGraphResponse` uses
`resources.ParseResource` (instead of `resources.Parse`) to validate the
environment ID is a named resource, rejecting collection or
custom-action IDs. The error is wrapped with `fmt.Errorf` for context.
- **Wiring**: `SetupRadiusCoreNamespace` in `pkg/corerp/setup/setup.go`
now registers `Custom["getGraph"]` on the `applications` resource,
analogous to the `Applications.Core/applications` registration.
- **Tests**: Unit test for the not-found path on the new controller,
plus a router assertion in `setup_test.go` that `POST
.../radius.core/applications/app0/getgraph` resolves to
`ACTIONGETGRAPH`. Additional tests targeting the lines flagged by
Codecov:
  - `ComputeGraphResponse` invalid-environment-ID error path.
- `ComputeGraphResponse` UCP error-propagation path, driven by an
`httptest` UCP server returning 500 on `/planes/radius/local/providers`.
- `ComputeGraphResponse` `listAllResourcesByApplication` error path
(lines 62-63), driven by an `httptest` server returning a resource type
then failing on `GetProviderSummary`.
- `ComputeGraphResponse` `listAllResourcesByEnvironment` error path
(lines 67-68), driven by an `httptest` server where application-scoped
listing succeeds but environment-scoped listing returns 500.
- Database error path through `GetGraph.Run` and
`GetGraphv20250801preview.Run` (non-`NotFound` `Get` error is
propagated).
- End-to-end success path through both `Run` methods into
`ComputeGraphResponse`, driven by an `httptest` UCP server returning an
empty providers list to yield an empty graph.

Coverage on the new shared helper rose from 0% to ~87.5%, both `Run`
methods are at 100%, and the `v20250801preview` getGraph package is at
100%.

```go
Custom: map[string]builder.Operation[datamodel.Application_v20250801preview]{
    "getGraph": {
        APIController: func(opt apictrl.Options) (apictrl.Controller, error) {
            return app_v20250801_ctrl.NewGetGraphv20250801preview(opt, *recipeControllerConfig.UCPConnection)
        },
    },
},
```

## Type of change

- This pull request fixes a bug in Radius and has an approved issue
(issue link required).

## Contributor checklist
Please verify that the PR meets the following requirements, where
applicable:

- An overview of proposed schema changes is included in a linked GitHub
issue.
    - [ ] Yes
    - [x] Not applicable
- A design document is added or updated under `eng/design-notes/` in
this repository, if new APIs are being introduced.
    - [ ] Yes
    - [x] Not applicable
- The design document has been reviewed and approved by Radius
maintainers/approvers.
    - [ ] Yes
    - [x] Not applicable
- A PR for
[resource-types-contrib](https://github.com/radius-project/resource-types-contrib/)
is created, if resource types or recipes are affected by the changes in
this PR.
    - [ ] Yes
    - [x] Not applicable
- A PR for [dashboard](https://github.com/radius-project/dashboard/) is
created, if the Radius Dashboard is affected by the changes in this PR.
    - [ ] Yes
    - [x] Not applicable
- A PR for the [documentation
repository](https://github.com/radius-project/docs) is created, if the
changes in this PR affect the documentation or any user facing updates
are made.
    - [ ] Yes
    - [x] Not applicable

---------

Signed-off-by: Will <28876888+willtsai@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: willtsai <28876888+willtsai@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Reshma Abdul Rahim <reshmarahim.abdul@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:standard Ongoing maintenance, minor improvements, documentation updates, and routine development work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Radius.Core/applications getGraph route returns 404 because backend action is not registered in UCP

4 participants